package com.car.loan.framework.task;

import com.car.loan.common.utils.qiniu.QiniuUtil;
import com.qiniu.common.QiniuException;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author huangding
 * @description
 * @date 2019/10/24 21:05
 */
@Component
public class UploadImageTask {

    @Autowired
    private QiniuUtil qiniuUtil;

    //    @Async("taskExecutor")
    public String uploadImage(byte[] buffer, String fileName) throws QiniuException {
        return qiniuUtil.uploadBase640(buffer, fileName);
    }

    @Async("taskExecutor")
    public void uploadImage(String url, String fileName) throws QiniuException {
        try {
            qiniuUtil.putUrl0(url, fileName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
